package cn.fang2chen.java.distributed.lock.framework;

import java.util.concurrent.TimeUnit;

/**
 * {@link RemoteLockSynchronizer 的装饰者}
 *
 * @author dcmini chen
 * @since 1.0.0
 */
public abstract class RemoteLockSyncDecorator implements RemoteLockSynchronizer{

    /**
     * 被装饰对象
     */
    public abstract RemoteLockSynchronizer remoteLockSynchronizer();

    @Override
    public void acquire( RemoteLockParam remoteLockParam) {
        remoteLockSynchronizer().acquire(remoteLockParam);
    }

    @Override
    public boolean tryAcquire( RemoteLockParam remoteLockParam) {
        return remoteLockSynchronizer().tryAcquire(remoteLockParam);
    }

    @Override
    public boolean tryAcquire( RemoteLockParam remoteLockParam, long time, TimeUnit unit) throws InterruptedException {
        return remoteLockSynchronizer().tryAcquire(remoteLockParam,time, unit);
    }

    @Override
    public boolean release( RemoteLockParam remoteLockParam) {
        return remoteLockSynchronizer().release(remoteLockParam);
    }

    @Override
    public boolean isLocked( RemoteLockParam remoteLockParam) {
        return remoteLockSynchronizer().isLocked(remoteLockParam);
    }

    @Override
    public long remainingTime( RemoteLockParam remoteLockParam) {
        return remoteLockSynchronizer().remainingTime(remoteLockParam);
    }

    @Override
    public void acquireInterruptibly( RemoteLockParam remoteLockParam) throws InterruptedException {
        remoteLockSynchronizer().acquireInterruptibly(remoteLockParam);
    }

    @Override
    public boolean isOwner( RemoteLockParam remoteLockParam) {
        return remoteLockSynchronizer().isOwner(remoteLockParam);
    }
}
